package com.ruoyi.system.service.zhaungxiuservice.shopService.impl;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.SupplierInfo;
import com.ruoyi.system.mapper.zhuangxiumapper.shopMapper.SupplierInfoMapper;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.zhaungxiuservice.shopService.SupplierInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierInfoServiceImpl implements SupplierInfoService {


    @Autowired(required = false)
    private SupplierInfoMapper supplierInfoMapper;

    @Autowired
    private ISysUserService sysUserService;

    @Override
    public SupplierInfo selectSupplierInfoById(Integer supplierId) {
        return supplierInfoMapper.selectSupplierInfoById(supplierId);
    }

    @Override
    public List<SupplierInfo> findAllAdder(SupplierInfo supplierInfo) {
        return supplierInfoMapper.findAllAdder(supplierInfo);
    }

    @Override
    public List<SupplierInfo> selectSupplierInfoList(SupplierInfo supplierInfo) {
        return supplierInfoMapper.selectSupplierInfoList(supplierInfo);
    }

    @Override
    public int addsi(SupplierInfo supplierInfo) {

//        supplierInfo.setSupplierCode("8888");
//        supplierInfo.setSupplierType(1);
//        supplierInfo.setSupplierTypeform(1);
//        supplierInfo.setSupplierStatus(0);
//        supplierInfo.setModifiedTime(new Date());

        return supplierInfoMapper.addsi(supplierInfo);
    }

    @Override
    public int updateSupplierInfo(SupplierInfo supplierInfo) {
        return supplierInfoMapper.updateSupplierInfo(supplierInfo);
    }

    @Override
    public int deleteSupplierInfoByIds(Integer[] supplierId) {
        return supplierInfoMapper.deleteSupplierInfoByIds(supplierId);
    }

    @Override
    public int deleteSupplierInfoById(Integer supplierId) {
        return supplierInfoMapper.deleteSupplierInfoById(supplierId);
    }

    @Override
    public int changeStatus(SupplierInfo supplierInfo) {

        return supplierInfoMapper.changeStatus(supplierInfo);
    }

    @Override
    public List<SupplierInfo> findAll(SupplierInfo supplierInfo) {
        return supplierInfoMapper.findAll(supplierInfo);
    }

    // TODO: 以下是超管的施工队店铺管理
    /**
     * 查询施工队的所有店铺信息
     * @return
     */
    public List<SupplierInfo> selectSuperTeamSupplierList(SupplierInfo supplierInfo){
        return supplierInfoMapper.selectSuperTeamSupplierList(supplierInfo);
    }

    /**
     * 修改施工队店铺状态
     */
    public int changeSuperTeamStatus(SupplierInfo supplierInfo){
        System.out.println("------------------------------supplierInfo:"+supplierInfo);
        SysUser user = new SysUser();
        user.setUserId(supplierInfo.getCustomerId());
        user.setStatus(supplierInfo.getSupplierStatus());
        sysUserService.updateUserStatus(user);
        return supplierInfoMapper.changeSuperTeamStatus(supplierInfo);
    }

    @Override
    public List<SupplierInfo> selectSuperTeamSupplierList() {
        return supplierInfoMapper.selectSuperTeamSupplierList();
    }


    //    TODO 超管 商品店铺
    @Override
    public SupplierInfo supeSuppListAllById(Integer supplierId) {
        return supplierInfoMapper.supeSuppListAllById(supplierId);
    }

    @Override
    public List<SupplierInfo> supeSuppListAll(SupplierInfo supplierInfo) {
        return supplierInfoMapper.supeSuppListAll(supplierInfo);
    }

    /**
     * 修改状态
     * @param supplierInfo
     * @return
     */
    public int changeSuperStatus(SupplierInfo supplierInfo){
        System.out.println("------------------------------supplierInfo:"+supplierInfo);
        SysUser user = new SysUser();
        user.setUserId(supplierInfo.getCustomerId());
        user.setStatus(supplierInfo.getSupplierStatus());
        sysUserService.updateUserStatus(user);
        return supplierInfoMapper.changeStatus(supplierInfo);
    }

    @Override
    public List<SupplierInfo> findAllUserId(SupplierInfo supplierInfo) {
        return supplierInfoMapper.findAllUserId(supplierInfo);
    }

    @Override
    public List<SupplierInfo> findAllStore() {
        return supplierInfoMapper.findAllStore();
    }

    @Override
    public List<SupplierInfo> findAllUserIdOne(SupplierInfo supplierInfo) {
        return supplierInfoMapper.findAllUserIdOne(supplierInfo);
    }
}
